<!DOCTYPE HTML>
<html th:with="title='新增模板'">
<head th:include="fragments/UEheader :: header">
</head>
<body id="app">
	<div class="page-container">
		<form action="/manager/appTemplate/save" method="post" class="form form-horizontal" id="form">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					名称：
				</label>
				<div class="formControls col-xs-4 col-sm-4">
					<input type="text" class="input-text size-L" id="name" name="name">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					分辨率：
				</label>
				<div class="formControls col-xs-4 col-sm-4 skin-minimal">
					<input type="text" class="input-text size-L" id="resolution" name="resolution">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					选择类型：
				</label>
				<div class="formControls col-xs-4 col-sm-4">
					<!--<select class="input-text size-L" id="templateType" name="templateType" onclick="queryTemplate();">-->
					<select class="input-text size-L" id="templateType" name="templateType">
						<option th:each="templateType:${templateTypes}" th:value="${templateType.id}" th:text="${templateType.templateTypeName}"></option>
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					屏幕设置：
				</label>
				<div class="formControls col-xs-4 col-sm-4">
					<span class="select-box">
						<select class="select size-L" id="showType" name="showType">
							<option value="0">横屏</option>
							<option value="1">竖屏</option>
							<option value="2">待设置</option>
						</select>
					</span>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					是否启用：
				</label>
				<div class="formControls col-xs-3 col-sm-3 skin-minimal">
					<div class="radio-box">
						<input type="radio" name="status" id="enable" value="1">
						<label for="enable">启用</label>
					</div>
					<div class="radio-box">
						<input type="radio" name="status" id="Discontinuation" value="0">
						<label for="enable">停用</label>
					</div>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary size-L radius" type="submit" value="提交">
					<input class="btn btn-primary size-L radius" type="button" onclick="closeWin()" value="关闭">
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript">
		var backgroundType = 0;
		function closeWin() {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
		$(function() {
			//adsQuery();
			/* 初始化单选框样式 */
			$('.skin-minimal input').iCheck({
				checkboxClass : 'icheckbox-blue',
				radioClass : 'iradio-blue',
				increaseArea : '20%'
			});
			$("#form").validate({
				rules : {
					name : {
						required : true
					},
					resolution : {
						required : true
					},
					template : {
						required : true
					},
					status : {
						required : true
					}
				},
				onkeyup : false,
				focusCleanup : true,
				success : "valid",
				submitHandler : function(form) {
					var data = $('#form').serialize();
					$.ajax({
						type : "POST",
						url : '/manager/appTemplate/save',
						data : data,
						beforeSend : function() {

						},
						complete : function() {

						},
						error : function(request) {
							layer.alert("系统出错");
						},
						success : function(data) {
							if (data.status == 0) {
								try {
									window.parent.adsQuery();
								} catch (e) {
									refreshUParentList();
								}
								layer.alert(data.message, function() {
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);
								});
							} else {
								layer.alert(data.message);
							}
						}
					});
				}
			});
		});
		/*
		 * 查询
		 */
		/*function adsQuery() {
			var tip = layer.load(0, {
				shade : false
			});
			$.ajax({
				type : "POST",
				url : '/manager/templateType/queryPage',
				beforeSend : function() {
				},
				complete : function() {
					layer.close(tip);
				},
				error : function(request) {
					layer.alert("系统错误");
				},
				success : function(result) {
					if (result.status == 0) {
						var data = result.data;
						for ( var i = 0; i < data.rows.length; i++) {
							$("#templateType").append("<option value='"+data.rows[i].id+"'>"+data.rows[i].templateTypeName+"</option>");
						}
					} else {
						sessionCheckTimeOut(result);
					}
				}
			});
		}*/

		/*var queryTemplate = function(){
			var userid = $("#operator").val()
			$.ajax({
				type : "POST",
				url : '/manager/templateType/findByUserId',
				data : {
					userid : userid,
				},
				beforeSend : function() {
				},
				complete : function() {
					layer.close(tip);
				},
				error : function(request) {
					layer.alert("系统错误");
				},
				success : function(result) {
					var data = result.data;
					var obj = document.getElementById("templateType");
					obj.options.length = 0;
					var bb = $(document).find("#templateType");
					for ( var i = 0; i < data.length; i++) {
						bb.append("<option value='" + data[i].id + "'>" + data[i].templateTypeName + "</option>");
					}
				}
			});
		}*/
	</script>
</body>
</html>